#include "WinUnit.h"
#include "VpipHandInfoBuilder.h"
#include "Hand.h"
#include "PlayerHandInfo.h"
#include <list>

using namespace std;

namespace
{
	VpipHandInfoBuilder builder;
	Hand h;	
}

BEGIN_TEST(CanDetectVpipTest)
{		
	list<Action> actions;
	actions.push_back(Action("player1", POST, 1));
	actions.push_back(Action("player2", POST, 2));
	actions.push_back(Action("player3", CALL, 2));
	actions.push_back(Action("player4", FOLD, 0));
	h.Actions(actions);
	
	list<Player> players;
	players.push_back(Player("player1", 1, 100, false, true, false));
	players.push_back(Player("player2", 2, 100, true, false, false));
	players.push_back(Player("player3", 3, 100, false, false, false));
	players.push_back(Player("player4", 4, 100, false, false, true));
	h.Players(players);

	HandInfo handInfo(h);
	builder.Fill(handInfo, h);

	WIN_ASSERT_TRUE(
		handInfo.PlayerInfo("player1").Vpip() == false
		&& handInfo.PlayerInfo("player2").Vpip() == false
		&& handInfo.PlayerInfo("player3").Vpip() == true
		&& handInfo.PlayerInfo("player4").Vpip() == false
	);
}
END_TEST

BEGIN_TEST(CanDetectVpipHuTest)
{		
	list<Action> actions;
	actions.push_back(Action("player1", POST, 1));
	actions.push_back(Action("player2", POST, 2));
	actions.push_back(Action("player1", CALL, 1));
	actions.push_back(Action("player2", CHECK, 0));
	h.Actions(actions);
	
	list<Player> players;
	players.push_back(Player("player1", 1, 100, false, true, true));
	players.push_back(Player("player2", 2, 100, true, false, false));
	h.Players(players);

	HandInfo handInfo(h);
	builder.Fill(handInfo, h);

	WIN_ASSERT_TRUE(
		handInfo.PlayerInfo("player1").Vpip() == true
		&& handInfo.PlayerInfo("player2").Vpip() == false
	);
}
END_TEST

BEGIN_TEST(CanDetectVpipHuTest2)
{		
	list<Action> actions;
	actions.push_back(Action("player1", POST, 1));
	actions.push_back(Action("player2", POST, 2));
	actions.push_back(Action("player1", RAISE, 5));
	actions.push_back(Action("player2", CALL, 4));
	h.Actions(actions);
	
	list<Player> players;
	players.push_back(Player("player1", 1, 100, false, true, true));
	players.push_back(Player("player2", 2, 100, true, false, false));
	h.Players(players);

	HandInfo handInfo(h);
	builder.Fill(handInfo, h);

	WIN_ASSERT_TRUE(
		handInfo.PlayerInfo("player1").Vpip() == true
		&& handInfo.PlayerInfo("player2").Vpip() == true
	);
}
END_TEST